package com.example.testapplication.ui.bubble;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;

import android.os.Bundle;

import com.example.testapplication.R;
import com.example.testapplication.databinding.ActivityBubbleBinding;
import com.example.testapplication.entity.Bubble;
import com.gyf.immersionbar.ImmersionBar;

import java.util.ArrayList;
import java.util.List;

import me.goldze.mvvmhabit.base.BaseActivity;
import me.tatarka.bindingcollectionadapter2.BR;

public class BubbleActivity extends BaseActivity<ActivityBubbleBinding,BubbleViewModel> {
    private List<Bubble> mWaters = new ArrayList<>();
    {
        for (int i = 0; i <10; i++) {
            mWaters.add(new Bubble("海豚物语"));
        }
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_bubble;
    }

    @Override
    public void initData() {
        binding.bubbleContainer.setBubbles(mWaters);
    }

    @Override
    protected boolean isStatusBarDarkFont() {
        return false;
    }

    @Override
    protected boolean isStatusBarEnabled() {
        return true;
    }

    @NonNull
    @Override
    protected ImmersionBar createStatusBarConfig() {
        return super.createStatusBarConfig();
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initViewObservable() {
        viewModel.uc.pClickEvent.observe(this, new Observer<Integer>() {
            @Override
            public void onChanged(Integer integer) {
                binding.bubbleContainer.setBubbles(mWaters);
            }
        });
    }
}